package tech.jabari.user.controller;

import tech.jabari.user.service.UserService;
import tech.jabari.user.service.impl.UserServiceImpl;

import javax.servlet.ServletException;
import javax.servlet.annotation.WebServlet;
import javax.servlet.http.HttpServlet;
import javax.servlet.http.HttpServletRequest;
import javax.servlet.http.HttpServletResponse;
import java.io.IOException;

/**
 * 批量删除用户
 */
@WebServlet("/batDelUser.action")
public class BatchDelUserServlet extends HttpServlet {
    private UserService userService = new UserServiceImpl();
    protected void doPost(HttpServletRequest request, HttpServletResponse response) throws ServletException, IOException {
        doGet(request, response);
    }

    protected void doGet(HttpServletRequest request, HttpServletResponse response) throws ServletException, IOException {
        //调用Service来删除用户
        String delIds = request.getParameter("delIds");
        int r = userService.batchDelUser(delIds);
        if (r > 0) {
            response.getWriter().write("OK");
        } else {
            response.getWriter().write("NO");
        }
    }
}
